<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>实体变更日志测试</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
</head>
<body>
    <div class="container-fluid mt-4">
        <h2>实体变更日志测试</h2>
        
        <div class="card mb-4">
            <div class="card-header">
                <h5>功能测试</h5>
            </div>
            <div class="card-body">
                <button class="btn btn-primary" onclick="checkEntityLogs()">检查实体日志记录</button>
                <button class="btn btn-secondary" onclick="getLatestLog()">获取最新日志</button>
            </div>
        </div>
        
        <div class="card">
            <div class="card-header">
                <h5>响应结果</h5>
            </div>
            <div class="card-body">
                <pre id="result" style="background-color: #f8f9fa; padding: 15px; border-radius: 5px;">
// 点击上面的按钮查看结果
                </pre>
            </div>
        </div>
    </div>
    
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
    <script>
        // 检查实体日志记录
        function checkEntityLogs() {
            $.get('/sys/entityChangeLog/check')
                .done(function(data) {
                    $('#result').text(JSON.stringify(data, null, 2));
                })
                .fail(function(xhr) {
                    $('#result').text('请求失败: ' + xhr.responseText);
                });
        }
        
        // 获取最新日志
        function getLatestLog() {
            $.get('/sys/log/list', { page: 1, limit: 1 })
                .done(function(data) {
                    if (data.code === 0 && data.page && data.page.list && data.page.list.length > 0) {
                        const latestLog = data.page.list[0];
                        $('#result').text('最新日志记录:\n' + JSON.stringify(latestLog, null, 2));
                    } else {
                        $('#result').text('未找到日志记录');
                    }
                })
                .fail(function(xhr) {
                    $('#result').text('请求失败: ' + xhr.responseText);
                });
        }
    </script>
</body>
</html>